



import { log } from 'console';
import { Searchtable } from './Table'
import { AdvancedSearchForm } from './searchFrom'
import { myOrder } from '@/api1/order'
import dayjs from 'dayjs';
import React, { useEffect, useState } from 'react';
interface DataType {
  prodName: string;
  prodCount: string;
  price: number;
  orderNumber:string,
  actualTotal:number,
  status:number,
  tags?: string[];
}
export const UserList: React.FC = () => {
  const [searchFormData, setSearchFormData] = useState<searchFromtype>({ size: '10', current: '1' });
  const [data, setData] = useState<DataType[]>([{
    prodName: '眼贴',
    prodCount: '2',
    price: 23,
    orderNumber: '345354444444444441213231',
    actualTotal: 59,
    status: 5
  }]); // Make data reactive

  let a = {
    SkinTotalScore: 80,//皮肤总分 
    Skinage: 30,//皮肤年龄
    FishtailPatternDegree: 0,//鱼尾纹程度 
    DegreeOfLegalPattern: 0,//法令纹程度 
    DegreeOfRaisedWrinkles: 0,//抬头纹程度 
    FishtailIndex: 0,//鱼尾纹指数
    LawPatternIndex: 0,//法令纹指数
    HeadLiftIndex: 0,//抬头纹指数
    EyebrowCreaseIndex: 0,//眉间纹指数
    FineGrainIndex: 0,//细纹指数
  }

  const handlePageChange = (page: number, pageSize?: number) => {
    // 这里可以添加处理分页逻辑，例如更新 searchFrom 中的 current 字段
    // 并且调用 getlist 方法来获取新的数据
    getlist({ ...searchFormData, current: page.toString(), size: pageSize?.toString() || '10' });
  };
  const getlist = (values: any) => {
    myOrder(values).then((e: any) => {
      setData(e)
    })

  };
  const handleSearch = (values: any) => {
    if (values.dateRange) {
      // const formattedDates = values.dateRange.map((date: string | number | Date | dayjs.Dayjs | null | undefined) => dayjs(date).format('YYYY-MM-DD'));
      let a = values.dateRange[0].format('YYYY-MM-DD')
      // values.dateRange[1]  =values.dateRange[0].format('YYYY-MM-DD')
      console.log(a, 'oooooooooooooooooooooooooo');
    }
    // console.log(   (values.dateRange[0]).format('YYYY-MM-DD'),'pppppppppppppppppp');
    // 在这里调用 getlist 方法，将表单值传递进去
    // getlist({ ...searchFormData, ...values, current: '1', size: '10' });
  };
  useEffect(() => {
    getlist({ ...searchFormData })
  }, []); // Empty dependency array means this effect runs once after the initial render
  return (
    <>
      <AdvancedSearchForm onSearch={handleSearch} />
      <Searchtable dataSource={data} onPageChange={handlePageChange} />
    </>
  );
};

